home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / CIncludes / DeskBus.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-12  |  8.2 KB  |  207 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        DeskBus.h
  3.  
  4.      Contains:    Apple Desktop Bus (ADB) Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1987-1997 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __DESKBUS__
  19. #define __DESKBUS__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27.  
  28.  
  29.  
  30. #if PRAGMA_ONCE
  31. #pragma once
  32. #endif
  33.  
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37.  
  38. #if PRAGMA_IMPORT
  39. #pragma import on
  40. #endif
  41.  
  42. #if PRAGMA_STRUCT_ALIGN
  43.     #pragma options align=mac68k
  44. #elif PRAGMA_STRUCT_PACKPUSH
  45.     #pragma pack(push, 2)
  46. #elif PRAGMA_STRUCT_PACK
  47.     #pragma pack(2)
  48. #endif
  49.  
  50. typedef SInt8                             ADBAddress;
  51. typedef CALLBACK_API( void , ADBCompletionProcPtr )(Ptr buffer, Ptr refCon, long command);
  52. /*
  53.     WARNING: ADBCompletionProcPtr uses register based parameters under classic 68k
  54.              and cannot be written in a high-level language without 
  55.              the help of mixed mode or assembly glue.
  56. */
  57. typedef CALLBACK_API( void , ADBDeviceDriverProcPtr )(SInt8 devAddress, SInt8 devType);
  58. /*
  59.     WARNING: ADBDeviceDriverProcPtr uses register based parameters under classic 68k
  60.              and cannot be written in a high-level language without 
  61.              the help of mixed mode or assembly glue.
  62. */
  63. /*
  64.     TempADBServiceRoutineUPP is needed because of circular definition of
  65.     ADBServiceRoutineProcPtr and ADBServiceRoutineUpp depending on each other.
  66. */
  67. typedef REGISTER_UPP_TYPE(ADBServiceRoutineProcPtr)             TempADBServiceRoutineUPP;
  68. typedef CALLBACK_API( void , ADBServiceRoutineProcPtr )(Ptr buffer, TempADBServiceRoutineUPP completionProc, Ptr refCon, long command);
  69. /*
  70.     WARNING: ADBServiceRoutineProcPtr uses register based parameters under classic 68k
  71.              and cannot be written in a high-level language without 
  72.              the help of mixed mode or assembly glue.
  73. */
  74. typedef REGISTER_UPP_TYPE(ADBCompletionProcPtr)                 ADBCompletionUPP;
  75. typedef REGISTER_UPP_TYPE(ADBDeviceDriverProcPtr)                 ADBDeviceDriverUPP;
  76. typedef REGISTER_UPP_TYPE(ADBServiceRoutineProcPtr)             ADBServiceRoutineUPP;
  77. /*
  78.     typedef pascal void (*ADBInitProcPtr)(SInt8 callOrder);
  79.  
  80.     Note: ADBInitProcPtr can only be created in 68K assembly language 
  81.           since it is a head patch that must JUMP to the previous address
  82. */
  83. struct ADBDataBlock {
  84.     SInt8                             devType;                    /* original handler ID */
  85.     SInt8                             origADBAddr;                /* original ADB Address */
  86.     ADBServiceRoutineUPP             dbServiceRtPtr;                /* service routine pointer */
  87.     Ptr                             dbDataAreaAddr;                /* this field is passed as the refCon parameter to the service routine */
  88. };
  89. typedef struct ADBDataBlock ADBDataBlock;
  90.  
  91. typedef ADBDataBlock *                    ADBDBlkPtr;
  92. struct ADBSetInfoBlock {
  93.     ADBServiceRoutineUPP             siService;                    /* service routine pointer */
  94.     Ptr                             siDataAreaAddr;                /* this field is passed as the refCon parameter to the service routine */
  95. };
  96. typedef struct ADBSetInfoBlock ADBSetInfoBlock;
  97.  
  98. typedef ADBSetInfoBlock *                ADBSInfoPtr;
  99. /* ADBOpBlock is only used when calling ADBOp from 68k assembly code */
  100. struct ADBOpBlock {
  101.     Ptr                             dataBuffPtr;                /* buffer: pointer to variable length data buffer */
  102.     ADBServiceRoutineUPP             opServiceRtPtr;                /* completionProc: completion routine pointer */
  103.     Ptr                             opDataAreaPtr;                /* refCon: this field is passed as the refCon parameter to the completion routine */
  104. };
  105. typedef struct ADBOpBlock ADBOpBlock;
  106.  
  107. typedef ADBOpBlock *                    ADBOpBPtr;
  108. EXTERN_API( void )
  109. ADBReInit                        (void)                                                        ONEWORDINLINE(0xA07B);
  110.  
  111. /*
  112.     ADBOp has a different interface for 68k assembly than for everything else
  113.     for 68k assembly the interface is 
  114.     #pragma parameter __D0 ADBOp(__A0,__D0)
  115.     OSErr ADBOp( ADBOpBlock * pb, short commandNum );
  116. */
  117. /*
  118.     IMPORTANT NOTE:
  119.     "Inside Macintosh: Devices" documents the completion routine for ADBOp will be called with
  120.     four parameters using 68k register based calling conventions, specifically the completion routine
  121.     passed in should be of type ADBServiceRoutineProcPtr. However, when upp types were first added
  122.     to this interface file, the type ADBCompletionUPP was mistakenly used for the second parameter
  123.     to ADBOp. Since applications have shipped using completion routines of type ADBCompletionUPP,
  124.     the mistake cannot be corrected.
  125.     The only difference between ADBServiceRoutineUPP and ADBCompletionUPP is the former takes an extra
  126.     argument which is a pointer to itself, fortunately not needed for PowerPC code.
  127.     For compatibility with existing 68k code, when an ADBOp completion routine is called,
  128.     68k register A1 will point to the completion routine, as documented in Inside Mac.
  129. */
  130. EXTERN_API( OSErr )
  131. ADBOp                            (Ptr                     refCon,
  132.                                  ADBCompletionUPP         compRout,
  133.                                  Ptr                     buffer,
  134.                                  short                     commandNum);
  135.  
  136.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  137.                                                                                             #pragma parameter __D0 CountADBs
  138.                                                                                             #endif
  139. EXTERN_API( short )
  140. CountADBs                        (void)                                                        ONEWORDINLINE(0xA077);
  141.  
  142.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  143.                                                                                             #pragma parameter __D0 GetIndADB(__A0, __D0)
  144.                                                                                             #endif
  145. EXTERN_API( ADBAddress )
  146. GetIndADB                        (ADBDataBlock *            info,
  147.                                  short                     devTableIndex)                        ONEWORDINLINE(0xA078);
  148.  
  149.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  150.                                                                                             #pragma parameter __D0 GetADBInfo(__A0, __D0)
  151.                                                                                             #endif
  152. EXTERN_API( OSErr )
  153. GetADBInfo                        (ADBDataBlock *            info,
  154.                                  ADBAddress             adbAddr)                            ONEWORDINLINE(0xA079);
  155.  
  156.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  157.                                                                                             #pragma parameter __D0 SetADBInfo(__A0, __D0)
  158.                                                                                             #endif
  159. EXTERN_API( OSErr )
  160. SetADBInfo                        (const ADBSetInfoBlock * info,
  161.                                  ADBAddress             adbAddr)                            ONEWORDINLINE(0xA07A);
  162.  
  163. enum { uppADBCompletionProcInfo = 0x007B9802 };                 /* register no_return_value Func(4_bytes:A0, 4_bytes:A2, 4_bytes:D0) */
  164. enum { uppADBDeviceDriverProcInfo = 0x00050802 };                 /* register no_return_value Func(1_byte:D0, 1_byte:D1) */
  165. enum { uppADBServiceRoutineProcInfo = 0x0F779802 };             /* register no_return_value Func(4_bytes:A0, 4_bytes:A1, 4_bytes:A2, 4_bytes:D0) */
  166. #define NewADBCompletionProc(userRoutine)                         (ADBCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBCompletionProcInfo, GetCurrentArchitecture())
  167. #define NewADBDeviceDriverProc(userRoutine)                     (ADBDeviceDriverUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBDeviceDriverProcInfo, GetCurrentArchitecture())
  168. #define NewADBServiceRoutineProc(userRoutine)                     (ADBServiceRoutineUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBServiceRoutineProcInfo, GetCurrentArchitecture())
  169. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  170.     /* CallADBCompletionProc can't be called from classic 68k without glue code */
  171. #else
  172.     #define CallADBCompletionProc(userRoutine, buffer, refCon, command)  CALL_THREE_PARAMETER_UPP((userRoutine), uppADBCompletionProcInfo, (buffer), (refCon), (command))
  173. #endif
  174. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  175.     #pragma parameter CallADBDeviceDriverProc(__A0, __D0, __D1)
  176.     void CallADBDeviceDriverProc(ADBDeviceDriverUPP routine, SInt8 devAddress, SInt8 devType) = 0x4E90;
  177. #else
  178.     #define CallADBDeviceDriverProc(userRoutine, devAddress, devType)  CALL_TWO_PARAMETER_UPP((userRoutine), uppADBDeviceDriverProcInfo, (devAddress), (devType))
  179. #endif
  180. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  181.     /* CallADBServiceRoutineProc can't be called from classic 68k without glue code */
  182. #else
  183.     #define CallADBServiceRoutineProc(userRoutine, buffer, completionProc, refCon, command)  CALL_FOUR_PARAMETER_UPP((userRoutine), uppADBServiceRoutineProcInfo, (buffer), (completionProc), (refCon), (command))
  184. #endif
  185.  
  186.  
  187. #if PRAGMA_STRUCT_ALIGN
  188.     #pragma options align=reset
  189. #elif PRAGMA_STRUCT_PACKPUSH
  190.     #pragma pack(pop)
  191. #elif PRAGMA_STRUCT_PACK
  192.     #pragma pack()
  193. #endif
  194.  
  195. #ifdef PRAGMA_IMPORT_OFF
  196. #pragma import off
  197. #elif PRAGMA_IMPORT
  198. #pragma import reset
  199. #endif
  200.  
  201. #ifdef __cplusplus
  202. }
  203. #endif
  204.  
  205. #endif /* __DESKBUS__ */
  206.  
  207.